<div id="global">
	<?php require_once '/template/left-sidebar.phtml';?>
	<div id="content-with-twoside">
		<div class="global-border">
			<h1><span><?php echo $this->escape($this->title);?></span></h1>
			<div class="global-content">
				<table id="tblMyHistory">
				<?php 
				$pb_bid_mapper = new Application_Model_ProductBuyBidMapper();
				for($i = 0; $i < sizeof($this->pbEntries); $i++){
					if($i % 2 == 0){
				?>
					<tr>
				<?php
					}
				?>
						<td>
							<div class="global-border <?php 
								if($this->pbEntries[$i]->status == "B"){echo "in-progress-border";}
								else if($this->pbEntries[$i]->status == "F" && $this->pbEntries[$i]->winner != NULL){echo "finish-border";}
								else {echo "fail-border";}
							?>">
								<h1>
									<a href='<?php echo $this->escape($this->action) . "/pid/" . $this->pbEntries[$i]->product_buy_id; ?>'>
										<?php echo $this->pbEntries[$i]->title;?>
									</a>
									<span style="float:right;">
										<?php 
										$pbbEntry = $pb_bid_mapper->findNoticeByPbIdOfferType($this->pbEntries[$i]->product_buy_id, "O");
										if(sizeof($pbbEntry) > 0){
											echo "1";
										}
										?>
										<?php
										if($this->pbEntries[$i]->status == "F" && $this->pbEntries[$i]->winner != NULL){ 
										?>
										<img src="/images/icons/tick.png" class="icon">
										<?php 
										}else if($this->pbEntries[$i]->status == "F" && $this->pbEntries[$i]->winner == NULL){
										?>
										<img src="/images/icons/cross.png" class="icon">
										<?php 
										}
										?>
									</span>
								</h1>
								<div class="global-content">
									<table>
										<tr>
											<td rowspan="2" style="width: 98px;">
												<img src="<?php echo $this->pbEntries[$i]->image;?>" width="98px" height="70px"></img>
											</td>
											<td>
												<?php echo $this->price . ": $" . $this->pbEntries[$i]->price;?>
												<br/>
												<?php 
													$startDate = $this->pbEntries[$i]->creation_time;
													$newDeadline = strtotime ( '+' . $this->pbEntries[$i]->day . ' day' , strtotime ( $startDate ) ) ;
													$newDeadline = date ( 'Y-m-j G:i:s' , $newDeadline );
													
													echo $this->deadline . ": " . $newDeadline;
												?>
											</td>
										</tr>
										<tr>
											<td>
												<div style="float: right;">
													<?php
														echo $this->user . ": " . $this->pbEntries[$i]->member_id . "<br/>";
														$startDate = $this->pbEntries[$i]->creation_time;
														$newStartDate = strtotime($startDate);
														$newStartDate = date ( 'Y-m-j' , $newStartDate );
														echo "@ " . $newStartDate;
													?>
												</div>
											</td>
										</tr>
									</table>
								</div>
							</div>
						</td>
					<?php			
						if($i % 2 == 0){
							if($i + 1 == sizeof($this->pbEntries)){
								echo "<td></td></tr>";
							}
						}
						else{
							echo "</tr>";
						}
					}
					?>
				</table>
			</div>
		</div>
	</div>
	<?php require_once '/template/right-sidebar.phtml';?>
</div>